//
// Created by xili on 2024/8/31 22:31.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int generateKey(int num1, int num2, int num3) {
        int ans = 0;
        int h = 1;
        for (int i = 1; i <= 4; i++) {
            ans += min({f(num1, i), f(num2, i), f(num3, i)}) * h;
            h *= 10;
        }
        return ans;
    }

    int f(int num, int i) {
        return num / i * 10 > 0 ? num % i * 10 : 0;
    }
};
